<?php 
session_start();
include('header.php');
include('menu.php');
include('config.php');
include_once('connection/connection.php');
$District_id=$_REQUEST['DT'];
$Block_id=$_REQUEST['BC'];
$type_scheme=$_REQUEST['TS'];

/*   sart code for back button   */
//$s=$_REQUEST['s'];
if($type_scheme==1)
{
 $type_scheme="P&T";
 $s=1;
}
if($type_scheme==1)
{
 $type_scheme="TSS(P&T)";
 $s=1;
}

if($type_scheme==2)
{
 $type_scheme="Piped";
 $s=2;
}
if($type_scheme==4)
{
 $type_scheme="Sanitary Diggs";
 $s=4;
}
/*    end code    */

if($type_scheme=='P')
	{
	$type_scheme='P&T';
	}
if($type_scheme=='TSS(P')
{
$type_scheme='TSS(P&T)';
}
function getName($colName,$id)
{
	$sqlgetName="select distinct ".$colName."_name from tbl_lookup_location where ".$colName."_id=".$id;
	$querygetName=mysql_query($sqlgetName);
	$rowgetName=mysql_fetch_row($querygetName);
	return $rowgetName[0];
}
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<script language="javascript" type="text/javascript">
function validate()
{
	valid = true;
	if (document.view_main_q1.district.selectedIndex == 0)
    {
        alert ( "Please select District Name" );
        valid = false;
    }
	if (document.view_main_q1.form_id.selectedIndex == 0)
    {
        alert ( "Please select Form Id" );
        valid = false;
    }
	return valid;
}	
</script>
<title> P&T </title>
</head>
<body>
<div>
<form action="" method="post" enctype="multipart/form-data" onSubmit="return validate()" name="view_main_q1">
	<table border="0" width="746" id="table1" cellspacing="0" cellpadding="0" style="padding:10px">
	<tr>
		<td height="29" align="left" valign="top" bgcolor="#C5D8EB" colspan="7">&nbsp;</td>
	</tr>
	<tr>
	<td bgcolor="#E5E5E5" align="center" colspan="7" style="padding-top:5px">
	<span lang="en-us">&nbsp;</span><span lang="en-us" style="font-size: 8.5pt"><font face="Verdana" color="#006699"><b><?php if($type_scheme=="P&T"){echo "P&T/TSS(P&T)";}elseif($type_scheme=="Sanitary Diggs"){echo "Sanitary Diggi";}else{ echo $type_scheme;}?> scheme wise list</b></font></span></td>
</tr>
<tr><td bgcolor="#E5E5E5" align="left" colspan="7">&nbsp;</td>
</tr>
<tr><td width="60" height="35" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><b>District</b></font></td>
  <td width="131" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><?php echo getName('district',$District_id);?></font></td>
  <td width="52" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><b>Block</b></font></td>
  <td width="137" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><?php echo getName('block',$Block_id);?></font></td>
  <td width="55" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><b>Scheme</b></font></td>
  <td width="155" align="left">&nbsp;<font face="Verdana" style="font-size: 8.5pt" color="#000000"><?php if($type_scheme=="P&T"){echo "P&T/TSS(P&T)";}elseif($type_scheme=="Sanitary Diggs"){echo "Sanitary Diggi";}else{ echo $type_scheme;}?></font></td>
  <td width="156" align="right"><a href="schemewiseListQ.php?scheme=<?php echo $s;?>"><font face="Verdana" style="font-size: 8.5pt" color="#993333"><b>Back</b></font></a></td>
</tr>
		
		<tr>
			<td colspan="7">
			
<table width="743" bgcolor="#FFFFFF" style="border:1px solid #999999">
  <tr bgcolor="#E5E5E5">
    <td width="54" style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Sr.No.</font></td>
    <td width="178" style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Gram Panchayat</font></td>
    <td width="166" style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Census Village Code</font></td>
    <td width="276" style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;Village</font></td>
    <td width="45" style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;View</font></td>
  </tr>
 <?php
 if($type_scheme=="P&T"){
 $qry="select DISTINCT village_id,type_scheme,id,panchayat_id,cvc from tbl_dtls_q1_main where district_id='$District_id' and block_id='$Block_id' and (type_scheme='P&T' or type_scheme='TSS(P&T)')";
 }else{
 $qry="select DISTINCT village_id,type_scheme,id,panchayat_id,cvc from tbl_dtls_q1_main where district_id='$District_id' and block_id='$Block_id' and type_scheme='$type_scheme'";
 }
$result=mysql_query($qry);
     $i=1;
    while($fetchedRow=mysql_fetch_array($result))
	  {
     $villageId=$fetchedRow['village_id']; 
	 $panchayat_id=$fetchedRow['panchayat_id']; 
	 $form_id= $fetchedRow['id']; 
	 //$_SESSION['frm_unique_id']=$form_id;   
 ?>
  <tr>
    <td style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;<?php echo $i;?></font></td>
    <td style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;<?php echo getName('panchayat',$panchayat_id);?></font></td>
    <td style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;<?php echo $fetchedRow['cvc'];?></font></td>
    <td style="border:1px solid #999999"><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;<?php echo getName('village',$villageId);?></font><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp;</font></td>
    <td style="border:1px solid #999999" align="center"><a href="q1.php?form_id=<?php echo $form_id;?>&page=<?php echo $type_scheme;?>" style="text-decoration:none"><img src="images/index.jpeg" width="16" height="16" border="0"></a></td>
  </tr>
  <?php
  $i++;
  }
  ?>
</table>			</td>
		</tr>
		<tr>
			<td colspan="7">&nbsp;</td>
		</tr>
	</table>
</form>
</div>
</body>
</html>
